/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.cs.mailbox.MailServiceException;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import java.io.IOException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AddDocumentRevision
/*    */   extends SaveDocument
/*    */ {
/*    */   private int mDocId;
/*    */   
/*    */   public AddDocumentRevision()
/*    */   {
/* 34 */     this.mOperation = MailboxOperation.AddDocumentRevision;
/*    */   }
/*    */   
/*    */   public AddDocumentRevision(int mailboxId, String digest, long msgSize, int folderId) {
/* 38 */     super(mailboxId, digest, msgSize, folderId, 0);
/* 39 */     this.mOperation = MailboxOperation.AddDocumentRevision;
/*    */   }
/*    */   
/*    */   public void setDocId(int docId) {
/* 43 */     this.mDocId = docId;
/*    */   }
/*    */   
/*    */   public int getDocId() {
/* 47 */     return this.mDocId;
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException {
/* 51 */     out.writeInt(this.mDocId);
/* 52 */     super.serializeData(out);
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException {
/* 56 */     this.mDocId = in.readInt();
/* 57 */     super.deserializeData(in);
/*    */   }
/*    */   
/*    */   public void redo() throws Exception {
/* 61 */     Mailbox mbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/* 62 */     OperationContext octxt = getOperationContext();
/*    */     try {
/* 64 */       mbox.addDocumentRevision(octxt, this.mDocId, getAuthor(), getFilename(), getDescription(), isDescriptionEnabled(), getAdditionalDataStream());
/*    */     } catch (MailServiceException e) {
/* 66 */       if (e.getCode() == "mail.ALREADY_EXISTS") {
/* 67 */         mLog.info("Document revision " + getMessageId() + " is already in mailbox " + mbox.getId());
/* 68 */         return;
/*    */       }
/* 70 */       throw e;
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/AddDocumentRevision.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */